<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>人员脚本导入</title>
    <#include "/pubHeadStyle.html">
</head>
<body>
<form class="layui-form" action="" style="padding: 10px 75px;">
    <div class="layui-upload-drag" type="file" name="xmlFile" id="xmlFile">
        <i class="layui-icon"></i>
        <p>点击上传，或将文件拖拽到此处</p>
    </div>
    <div class="layui-btn-container layui-footer" style="position: absolute;left:37%;bottom:0">
        <button type="button" class="layui-btn layui-btn-sm" id="importButton">导入</button>
        <button class="layui-btn layui-btn-sm layui-btn-danger" id="return">取消</button>
    </div>
</form>

<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','element', 'upload', 'jquery'], function () {
        var element = layui.element;
        var upload = layui.upload;
        var $ = layui.$;
        var setter = layui.setter;
        var layer = layui.layer;

        var index = parent.layer.getFrameIndex(window.name);
        $('#return').click(function () {
            parent.layer.close(index);
        })
        //指定允许上传的文件类型
        upload.render({
            elem: '#xmlFile'
            , url: serverPath.workflowPath + setter.workflowLinkPath + 'personScript/importXml'
            , accept: 'file'
            , multiple: true
            , auto: false //选择文件后不自动上传
            , bindAction: '#importButton' //指向一个按钮触发上传
            , before: function (obj) {
            }
            , done: function (res) {
                if (res.code == 1) {
                    if(res.data){
                        layer.alert(res.data, {icon: 2, time: 2500});
                    }else{
                        layer.alert(res.msg , {icon: 2, time: 2500});
                    }
                } else {
                    layer.alert(res.msg,{icon: 1, time: 2500}, function (index) {
                        layer.close(index);
                        var index2 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index2); //再执行关闭
                        layui.needReload=true;
                    });
                }
            }
        });
    })
</script>
</body>
</html>